package com.zyb.patient.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.zyb.patient.dto.BaseDto;
import com.zyb.patient.util.Options;

public class ModelAdapter extends BaseAdapter {

	private ImageLoader imageLoader;
	private DisplayImageOptions options;
	private Context context;
	private List<BaseDto> list;
	private LayoutInflater inflater;

	public ModelAdapter(Context context, List<BaseDto> list, ImageLoader loader) {
		this.context = context;
		this.list = list;
		this.imageLoader = loader;
		options = Options.getListOptions();
		inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public BaseDto getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
//		NewDto nDto = list.get(position);
//		if (convertView == null) {
//			convertView = inflater.inflate(
//					R.layout.layout_frame1_listview_content_item, null);
//			holder = new ViewHolder();
//			holder.layout1 = (RelativeLayout) convertView
//					.findViewById(R.id.layout1);
//			convertView.setTag(holder);
//		} else {
//			holder = (ViewHolder) convertView.getTag();
//		}
//			if (!StringUtil.isEmpty(nDto.url1)) {
//				imageLoader.displayImage(nDto.url1, holder.ivPreview, options);
//			}
//			holder.tvTitle2.setText(nDto.title);
//			if (!StringUtil.isEmpty(nDto.date)) {
//				holder.tvDate2.setText(DateFormatUtil.getTimeGap3(nDto.date,
//						new Date()));
//			}
//		}
		return convertView;
	}

	static class ViewHolder {
		RelativeLayout layout1;
		LinearLayout layout2;
		TextView tvTitle1;
		TextView tvContent1;
		TextView tvDate1;
		ImageView ivPreview;
		TextView tvTitle2;
		TextView tvDate2;
		ImageView ivPreview1;
		ImageView ivPreview2;
		ImageView ivPreview3;
		ImageView rules;
		TextView rules2;

	}

}
